package com.example.taximeter.mapper;

import com.example.taximeter.bean.Fact;
import com.example.taximeter.bean.ParamFileView;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 计价器厂商
 */
@Mapper
public interface FactMapper {

    //查询计价器厂商列表
    @Select("select id , fact_name from tab_dict_jjq_fact")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "factname", column = "fact_name")
    })
    List<Fact> findFactList();

    //查询计价器厂商(厂商名称)
    @Select("select id , fact_name from tab_dict_jjq_fact where fact_name = #{factname,jdbcType=VARCHAR} ")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "factname", column = "fact_name")
    })
    List<Fact> findFactByFactname(@Param("factname") String factname);


    //新增计价器厂商
    @Insert("insert into tab_dict_jjq_fact (fact_name,memo)\n" +
            "    values (#{factname,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}) ")
    Boolean addFact(Fact fact);

    //修改计价器厂商
    @Update("update tab_dict_jjq_fact set fact_name = #{factname,jdbcType=VARCHAR},memo = #{memo,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER}")
    boolean updateFact(Fact fact);


    //删除计价器厂商
    @Delete("delete from tab_dict_jjq_fact  where id = #{id,jdbcType=INTEGER}")
    boolean deleteFact(Integer id);

    //查询计价器厂商列表
    @SelectProvider(type = ActivityMapperProvider.class, method = "findFactAll")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "factname", column = "fact_name"),
            @Result(property = "memo", column = "memo")

    })
    List<Fact> findFactAll(Fact fact);

    //查询计价器厂商(id)
    @Select("select fact_name from tab_dict_jjq_fact where id = #{id,jdbcType=INTEGER} ")
    @Results({
            @Result(property = "factname", column = "fact_name")
    })
    String findFactnameByFactid(@Param("id") Integer id);
}
